<script lang='tsx' name='Theme' setup>
import ThemeItem from './components/theme-item.vue'
import useSettingStore, { ThemeType } from "@/stores/setting";

const settingStore = useSettingStore()

enum activeType {
    theme = 'theme',
    avatar = 'avatar'
}


const active = ref(activeType.theme)

function ontoggle(type: activeType) {
    active.value = type
}

function changeTheme(type: ThemeType) {
    settingStore.theme = type
}
</script>

<template>
    <div class='theme-container'>
        <div class="title">
            <span :class="{ active: active === 'theme' }" @click="ontoggle(activeType.theme)">个性皮肤</span>
            <span :class="{ active: active === 'avatar' }" @click="ontoggle(activeType.avatar)">头像挂件</span>
        </div>
        <div class="theme-box">
            <ThemeItem v-for="(item, idx) in settingStore.themeList" :key="item.type"
                :selected="item.type === settingStore.theme" v-bind="item" @click="changeTheme(item.type)"></ThemeItem>
        </div>
    </div>
</template>

<style lang='scss' scoped>
.active {
    font-weight: bold;
}

.theme-container {
    padding-top: 20px;

    .title {
        font-size: 20px;
        @include flex-item-center();
        gap: 30px;
        cursor: pointer;
    }

    .theme-box {
        @include flex-item-center();
        gap: 14px;
        margin-top: 40px;
    }
}
</style>
